<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>内置函数的生命周期</title>
</head>
<body>
    
    <div id="app">{{v1}}</div>
    
    <script src="../lib/vue.min.js"></script>
    <script>
    var vm = new Vue({
        el: "#app",
        data: {
            v1: 1
        },
        beforeCreate: function() {
            console.log("beforeCreate")
        },
        created() {
            console.log("created")
            console.log(this.v1)
        },
        beforeMount: function() {
            console.log("beforeMount")
            console.log(this.v1)
        },
        mounted() {
            console.log("mounted")
            console.log(this.v1)
        },

        beforeUpdate() {
            console.log("beforeUpdate")
            console.log(this.v1)
        },
        updated() {
            console.log("updated")
            console.log(this.v1)
        },

        beforeDestroy() {
            console.log("beforeDestroy")
            console.log(this.v1)
        },
        destroyed() {
            console.log("destroyed")
            console.log(this.v1)
        },
    })
    setTimeout(() => {
        vm.v1 = 2
    }, 1000 * 2);

    setTimeout(() => {
        vm.v1 = 4
        vm.destory()
    }, 1000 * 2);
    </script>
</body>
</html>